<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<!DOCTYPE html>
<html>
<head>
    <title>项目信息表</title>
    <meta name="decorator" content="form"/>
    <html:css name="bootstrap-fileinput" />
    <html:css name="simditor,jquery-select2" />
    <html:js name="jquery-select2"/>
</head>

<body class="white-bg"  formid="eqProjectInfoForm">
    <form:form id="eqProjectInfoForm" modelAttribute="data" action="${adminPath}/sbfb/eqprojectinfo/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="province"/>
		<form:hidden path="city"/>
		<%-- <form:hidden path="manageUnit"/> --%>
		<table  class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
		   <tbody>
				<tr>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>项目名称:</label>
		            </td>
					<td class="width-35">
						<form:input path="name" htmlEscape="false" class="form-control"  datatype="*"    />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>项目编号:</label>
		            </td>
					<td class="width-35">
						<form:input path="code" htmlEscape="false" class="form-control"  datatype="*"    />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
<%-- 				<tr>
					<td  class="width-15 active text-right">	
		              <label>经度:</label>
		            </td>
					<td class="width-35">
						<form:input path="longtitude" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label>纬度:</label>
		            </td>
					<td class="width-35">
						<form:input path="latitude" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
				</tr> --%>
				<tr>
					<td  class="width-15 active text-right">	
		              <label>项目描述:</label>
		            </td>
					<td class="width-35">
						<form:input path="projectDesc" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label>项目经理:</label>
		            </td>
					<td class="width-35">
						<form:input path="manager" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label>联系人:</label>
		            </td>
					<td class="width-35">
						<form:input path="contact" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label>项目来源:</label>
		            </td>
					<td class="width-35">
						<form:input path="source" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label>项目规模:</label>
		            </td>
					<td class="width-35">
						<form:input path="prjectScale" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label>管理模式:</label>
		            </td>
					<td class="width-35">
						<form:input path="manageMode" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label>项目状态:</label>
		            </td>
					<td class="width-35">
						<form:select path="projectStatus" htmlEscape="false" class="form-control"    dict="eq_project_info.project_status"  />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label>管控模式:</label>
		            </td>
					<td class="width-35">
						<form:input path="mcontrolMode" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label>行业:</label>
		            </td>
					<td class="width-35">
						<form:input path="trade" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label>地址:</label>
		            </td>
					<td class="width-35">
						<form:input path="address" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>省份:</label>
		            </td>
					<td class="width-35">
						<form:select path="provinceCode" htmlEscape="false" class="form-control"        />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>地市:</label>
		            </td>
					<td class="width-35">
						<form:select path="cityCode" htmlEscape="false" class="form-control"        />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label>项目类型:</label>
		            </td>
					<td class="width-35">
						<form:select path="projectType" htmlEscape="false" class="form-control"  dict="eq_project_info.project_type"    />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>工期:</label>
		            </td>
					<td class="width-35">
						<form:input path="projectTimeLimit" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label>公路类型:</label>
		            </td>
					<td class="width-35">
						<form:select path="roadType" htmlEscape="false" class="form-control"  dict="eq_project_info.road_type"    />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label>工程类型:</label>
		            </td>
					<td class="width-35">
						<form:select path="engineeringType" htmlEscape="false" class="form-control"  dict="eq_project_info.engineering_type"    />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>拟竣工日期:</label>
		            </td>
					<td class="width-35">
						<form:input path="finishDatePlan" htmlEscape="false" class="form-control layer-date" placeholder="YYYY-MM-DD" onclick="laydate({format: 'YYYY-MM-DD'})"       />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label>竣工日期:</label>
		            </td>
					<td class="width-35">
						<form:input path="finishDate" htmlEscape="false" class="form-control layer-date" placeholder="YYYY-MM-DD" onclick="laydate({format: 'YYYY-MM-DD'})"       />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>拟开式日期:</label>
		            </td>
					<td class="width-35">
						<form:input path="startDatePlan" htmlEscape="false" class="form-control layer-date" placeholder="YYYY-MM-DD" onclick="laydate({format: 'YYYY-MM-DD'})"       />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label>开式日期:</label>
		            </td>
					<td class="width-35">
						<form:input path="startDate" htmlEscape="false" class="form-control layer-date" placeholder="YYYY-MM-DD" onclick="laydate({format: 'YYYY-MM-DD'})"       />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label>所属组织:</label>
		            </td>
					<td class="width-35">
						<%-- <form:input path="orgName" htmlEscape="false" class="form-control"      /> --%>						
					   <form:treeselect  title="请选择默认组织机构" path="orgId"  nested="true" datatype="*" nullmsg="请选择所属组织" callback="setCallBack"
					   		dataUrl="${adminPath}/sys/organization/treeData" labelName="orgName" labelValue="${data.orgName}" />
					   		
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label>核算组织:</label>
		            </td>
					<td class="width-35">
						<%-- <form:input path="orgAdjustAccounts" htmlEscape="false" class="form-control"      />--%>
					   <form:treeselect  title="请选择默认组织机构" path="orgAdjustAccountsId"  nested="true" datatype="*" nullmsg="请选择所属组织" callback="setCallBack"
					   		dataUrl="${adminPath}/sys/organization/treeData" labelName="orgAdjustAccounts" labelValue="${data.orgAdjustAccounts}" />	
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>管理单位:</label>
		            </td>
					<td class="width-35">
						<%-- <form:select path="manageUnitId" htmlEscape="false" class="form-control"      /> --%>
						
					   <form:treeselect  title="请选择默认组织机构" path="manageUnitId"  nested="true" datatype="*" nullmsg="请选择所属组织" callback="setCallBack"
					   		dataUrl="${adminPath}/sys/organization/treeData" labelName="manageUnit" labelValue="${data.manageUnit}" />	
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>分公司:</label>
		            </td>
					<td class="width-35">						
					   <form:treeselect  title="请选择默认组织机构" path="orgId"  nested="true" datatype="*" nullmsg="请选择所属公司" callback="setCallBack"
					   		dataUrl="${adminPath}/sys/organization/treeData" labelName="orgId" labelValue="${data.orgName}" />	
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label>成本模式:</label>
		            </td>
					<td class="width-35">
						<form:input path="costMode" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label>纳税方式:</label>
		            </td>
					<td class="width-35">
						<form:input path="taxMode" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
		  		</tr>
		   </tbody>
		</table>   
	</form:form>
<!-- 	<button id="save" onclick="dosave">保存</button>
	
	<button id="close"  onclick="doclose">取消</button>
	
	<div class="layui-layer-btn"><a class="layui-layer-btn0" onclick="dosave">确定</a><a class="layui-layer-btn1">关闭</a></div> -->
<html:js name="bootstrap-fileinput" />
<html:js name="simditor" />
<script>
function dosave(){
	document.getElementById("eqProjectInfoForm").submit();
}

var provinceCode="";
var cityCode="";
var filiale="";
$(function() {
	bindCity();
	getSelectProvince(); 
	//getSelectFiliale(); 
	
})


//绑定分公司
function getSelectFiliale() {
	filiale = $("#manageUnit").val();
	$("#manageUnitId").change(function(){
		$("#manageUnit").val($("#manageUnitId").find("option:selected").text());
		console.log("manageUnit:"+$("#manageUnit").val());
	});
    $.ajax({
        type: "POST",
        url: "${adminPath}/xmgl/xmglfiliale/ajaxList",
        data: {'page.size':100,queryFields:'orgId,name,'},
        dataType: "json",
        success: function (data) {
            var select = $("#manageUnitId");
        	
            select.empty();
        	if(data && data.total>0){            	
                var str = "<option value=''>请选择</option>";
                select.append(str);
                if (null != data && data.results.length > 0) {
                    $.each(data.results, function (i, item) {
                        if(filiale && item.id==filiale){
                            str = "<option value=" + item.orgId + " selected>" + item.name + "</option>";
                            select.append(str);
                            var event = document.createEvent("HTMLEvents");
                            event.initEvent("change", true, true);
                            document.querySelector("#manageUnitId").dispatchEvent(event);
                        }else{
                            str = "<option value=" + item.orgId + ">" + item.name + "</option>";
                            select.append(str);
                        }
                    });
                } else {
                    console.log("data is null");
                }
        	}

        }
    });
}

//绑定省
function getSelectProvince() {
	provinceCode = $("#province").val();
	$("#provinceCode").change(function(){
		$("#province").val($("#provinceCode").find("option:selected").text());
		console.log("province:"+$("#province").val());
	});
    $.ajax({
        type: "POST",
        url: "${adminPath}/project/locationofprovinces/ajaxList",
        data: {'page.size':100,queryFields:'provinceCode,provinceName,'},
        dataType: "json",
        success: function (data) {
            var select = $("#provinceCode");
        	
            select.empty();
        	if(data && data.total>0){            	
                var str = "<option value=''>请选择</option>";
                select.append(str);
                if (null != data && data.results.length > 0) {
                    $.each(data.results, function (i, item) {
                        if(provinceCode && item.provinceCode==provinceCode){
                            str = "<option value=" + item.provinceCode + " selected>" + item.provinceName + "</option>";
                            select.append(str);
                            var event = document.createEvent("HTMLEvents");
                            event.initEvent("change", true, true);
                            document.querySelector("#provinceCode").dispatchEvent(event);
                        }else{
                        	if('520000'==item.provinceCode){                          
                        		str = "<option value=" + item.provinceCode + " selected>" + item.provinceName + "</option>";
                                select.append(str);
                                var event = document.createEvent("HTMLEvents");
                                event.initEvent("change", true, true);
                                document.querySelector("#provinceCode").dispatchEvent(event);
                        	}else{
                                str = "<option value=" + item.provinceCode + ">" + item.provinceName + "</option>";
                                select.append(str);
                        	}
                        }
                    });
                } else {
                    console.log("data is null");
                }
        	}

        }
    });
}

//绑定地市
function bindCity() {

	cityCode = $("#city").val();
	$("#cityCode").change(function(){
		$("#city").val($("#cityCode").find("option:selected").text());
		console.log("city:"+$("#city").val());
	});

	$("#provinceCode").change(function(){				
		$("#province").text(this.selectedOptions[0].innerText);
      	var provinceCode = this.value;
      	if(provinceCode){
      		provinceCode = provinceCode.substring(0,2);
      	}
      	
		$.ajax({
		      type: "POST",
		      url: "${adminPath}/project/locationofcitys/ajaxList",
		      data: {'page.size':300,queryFields:'cityName,cityCode,','provinceCode':provinceCode},
		      dataType: "json",
		      success: function (data) {
		    	var select = $("#cityCode");
		    	select.empty();
		      	if(data && data.total>0){            	
		              var str = "<option value=''>请选择</option>";
		              select.append(str);
		              if (null != data && data.results.length > 0) {
		                  $.each(data.results, function (i, item) {
		                      if(cityCode && item.cityCode==cityCode){
		                          str = "<option value=" + item.cityCode + " selected>" + item.cityName + "</option>";
			                      select.append(str);
	                              var event = document.createEvent("HTMLEvents");
	                              event.initEvent("change", true, true);
	                              document.querySelector("#cityCode").dispatchEvent(event);
	                              
		                      }else{
			                      str = "<option value=" + item.cityCode + ">" + item.cityName + "</option>";
			                      select.append(str);
		                      }
		                  });
		              } else {
		                  console.log("data is null");
		              }
		      	}

		      }
		  });
	});
  
	
}
</script>
</body>
</html>